
<?php include './application/views/top.php'; ?>
<script src="/static/js/gsdai.js"></script>
<script src="/static/js/ajaxfileupload.js"></script>
<script src="/static/js/My97DatePicker/WdatePicker.js"></script>
<script src="/static/js/formCheck.js"></script>

<div class="clear"></div>
<div class="user_bottom all"></div>
<div class="clear h50"></div>
<div class="layout uc">
	<?php include './application/views/user/left.php'; ?>
	<div class="right">
		<div class="menu_list"><?php include './application/views/user/menu.php'; ?></div>
        <div class="cont">
        	<ul class="tbt">
	            <?php if($type == 3 || $type == 4 || $type == 5){?>
            	<li class="w158">标题</li>
                <li class="w80">类型</li>
                <li class="w80">金额</li>
                <li class="w80">年利率</li>
                <li class="w80">期限</li>
                <li class="w80">还款时间</li>
				<li class="w80">逾期时间</li>
                <li class="w80">逾期费用</li>
                <?php }else{?>
            	<li class="w168">标题</li>
                <li class="w110">类型</li>
                <li class="w110">金额</li>
                <li class="w110">年利率</li>
                <li class="w110">期限</li>
                <li class="w110">还款时间</li>
                <?php }?>
                <li class="w100">期数</li>
                <li class="w100 npr">操作</li>
			</ul>
            <?php $i=0; foreach($borrow_list as $borrow){?>
        	<ul class="tbc">
            	<?php if($type == 3 || $type == 4 || $type == 5){?>
                <?php $late_result = late_interest($borrow['repayment_time'], $borrow['capital']>0?$borrow['capital']:$borrow['interest']);?>
            	<li class="w158"><a href="/borrow/obj/<?php echo $borrow['borrow_id'];?>.html" target="_blank"><?php echo $borrow['title'];?></a></li>
            	<li class="w80"><?php echo @$borrow_type[$borrow['ftype']];?></li>
            	<li class="w80">&yen;<?php echo number_format($borrow['repayment_account'],2);?>元</li>
                <li class="w80"><?php echo $borrow['apr'];?>%</li>
                <li class="w80"><?php if($borrow['is_day'] == 1){echo $borrow['time_limit_day'].'天';}else{ echo $borrow['time_limit'].'个月';}?></li>
            	<li class="w80"><?php echo date('Y-m-d',$borrow['repayment_time']);?></li>
				<?php if($type == 3 || $type == 5){?>
                <li class="w80"><?php echo $late_result['late_days'];?>天</li>
                <li class="w80">&yen;<?php echo number_format($late_result['late_interest'],2);?>元</li>
				<?php }elseif($type == 4){?>
                <li class="w80"><?php echo $borrow['late_days'];?>天</li>
                <li class="w80">&yen;<?php echo number_format($borrow['late_interest'],2);?>元</li>
                <?php }?>
                <?php } else {?>
            	<li class="w168"><a href="/borrow/obj/<?php echo $borrow['borrow_id'];?>.html" target="_blank"><?php echo $borrow['title'];?></a></li>
            	<li class="w110"><?php echo @$borrow_type[$borrow['ftype']];?></li>
            	<li class="w110">&yen;<?php echo number_format($borrow['repayment_account'],2);?>元</li>
                <li class="w110"><?php echo $borrow['apr'];?>%</li>
                <li class="w110"><?php if($borrow['is_day'] == 1){echo $borrow['time_limit_day'].'天';}else{ echo $borrow['time_limit'].'个月';}?></li>
            	<li class="w110"><?php echo date('Y-m-d',$borrow['repayment_time']);?></li>
                <?php }?>
                <li class="w100"><?php echo $borrow['forder']+1;?>/<?php echo $borrow['time_limit'];?></li>
            	<li class="w100 npr">
				<?php if($borrow['ftype'] == 4){?>
                <?php if($borrow['fstatus']==0){?><a href="javascript:if(confirm('你确定还款？')){lz_repay(<?php echo $borrow['id'];?>);}">还款</a><?php }?>
                <?php }else{?>
                <?php if($borrow['fstatus']==0){?><a href="javascript:if(confirm('你确定还款？')){repay(<?php echo $borrow['id'];?>);}">还款</a><?php }?>
                <?php }?>
                </li>
			</ul>
            <?php $i++; }?>
        </div>
        <div class="clear h30"></div>
        <div class="page">
            <div class="pagination">
            <?php echo $this->pagination->create_links();?>
            </div>
        </div>
	</div>
</div>
<div class="clear h50"></div>
<?php include "./application/views/footer.php";?>
<script>
function repay(repayment_id){
	$.ajax({
		type: "get",
		url: "/userborrow/repay/"+repayment_id,
		success: function(msg){
			$("#dialog" ).dialog();
			if(msg == 1){
				$("#msg").html("还款成功！");
				$("#borrow_"+repayment_id).hide();
			}else{
				$("#msg").html(msg);
			}
			setTimeout(function(){
				$("#dialog").dialog("close");
			},3000);
		},
		dataType: "text"
	});
}
function lz_repay(collection_id){
	$.ajax({
		type: "get",
		url: "/userborrow/lz_repay/"+collection_id,
		success: function(msg){
			$("#dialog" ).dialog();
			if(msg == 1){
				$("#msg").html("还款成功！");
				$("#borrow_"+collection_id).hide();
			}else{
				$("#msg").html(msg);
			}
			setTimeout(function(){
				$("#dialog").dialog("close");
			},3000);
		},
		dataType: "text"
	});
}
</script>